#include <cstdio>
#include <cstring>
#include <cmath>
#define ll long long

using namespace std;

class BigNum
{
    public:
        void output( );
        BigNum( ) { len = 1; num[ 0 ] = 0; }
        BigNum &operator = ( const BigNum & );
        BigNum &operator = ( const int & );
        friend bool operator <= ( const BigNum & , const BigNum & );
        friend bool operator < ( const BigNum & , const BigNum & );
        friend bool operator == ( const BigNum & , const BigNum & );
        friend bool operator == ( const BigNum & , const int & );
        friend bool operator != ( const BigNum & , const BigNum & );
        friend bool operator != ( const BigNum & , const int & );
        friend BigNum operator + ( const BigNum & , const BigNum & );
        friend BigNum operator - ( const BigNum & , const BigNum & );
        friend BigNum operator * ( const BigNum & , const BigNum & );
        friend BigNum operator / ( const BigNum & , const BigNum & );
        friend BigNum operator % ( const BigNum & , const BigNum & );
        friend BigNum operator + ( const BigNum & , const int & );
        friend BigNum operator - ( const BigNum & , const int & );
        friend BigNum operator * ( const BigNum & , const int & );
        friend BigNum operator / ( const BigNum & , const int & );
        friend BigNum operator % ( const BigNum & , const int & );
        friend void operator += ( BigNum & , const BigNum & );
        friend void operator -= ( BigNum & , const BigNum & );
        friend void operator *= ( BigNum & , const BigNum & );
        friend void operator /= ( BigNum & , const BigNum & );
        friend void operator %= ( BigNum & , const BigNum & );
        friend void operator += ( BigNum & , const int & );
        friend void operator -= ( BigNum & , const int & );
        friend void operator *= ( BigNum & , const int & );
        friend void operator /= ( BigNum & , const int & );
        friend void operator %= ( BigNum & , const int & );
        int len, num[ 25 ];
};

void BigNum::output( )
{
    int i;
    printf("%d", num[ len - 1 ]);
    for ( i = len - 2; i >= 0; i-- )
        printf("%04d", num[ i ]);
}

BigNum &BigNum::operator = ( const BigNum &a )
{
    int i;
    len = a.len;
    for ( i = 0; i < a.len; i++ )
        num[ i ] = a.num[ i ];
    return *this;
}

BigNum &BigNum::operator = ( const int &b )
{
    int a = b;
    len = 0;
    num[ 0 ] = 0;
    while ( a )
    {
        num[ len++ ] = a % 10000;
        a /= 10000;
    }
    if ( !len )
        len = 1;
    return *this;
}

bool operator <= ( const BigNum &a, const BigNum &b )
{
    if ( a.len < b.len )
        return true;
    if ( a.len > b.len )
        return false;
    int i;
    for ( i = a.len - 1; i >= 0; i-- )
    {
        if ( a.num[ i ] < b.num[ i ] )
            return true;
        if ( a.num[ i ] > b.num[ i ] )
            return false;
    }
    return true;
}

bool operator < ( const BigNum &a, const BigNum &b )
{
    if ( a.len < b.len )
        return true;
    if ( a.len > b.len )
        return false;
    int i;
    for ( i = a.len - 1; i >= 0; i-- )
    {
        if ( a.num[ i ] < b.num[ i ] )
            return true;
        if ( a.num[ i ] > b.num[ i ] )
            return false;
    }
    return false;
}

bool operator == ( const BigNum &a, const BigNum &b )
{
    if ( a.len != b.len )
        return false;
    int i;
    for ( i = 0; i < a.len; i++ )
        if ( a.num[ i ] != b.num[ i ] )
            return false;
    return true;
}

bool operator == ( const BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    return a == c;
}

bool operator != ( const BigNum &a, const BigNum &b )
{
    if ( a.len != b.len )
        return true;
    int i;
    for ( i = 0; i < a.len; i++ )
        if ( a.num[ i ] != b.num[ i ] )
            return true;
    return false;
}

bool operator != ( const BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    return a != c;
}

BigNum operator + ( const BigNum &c, const BigNum &b )
{
    int i, j;
    BigNum a;
    a = c;
    for ( i = 0; i < b.len; i++ )
    {
        if ( i < a.len )
            a.num[ i ] += b.num[ i ];
        else
        {
            a.num[ i ] = b.num[ i ];
            a.len++;
        }
    }
    for ( i = 0; i < a.len; i++ )
        if ( a.num[ i ] >= 10000 )
        {
            if ( i == a.len - 1 && i < 24 )
            {
                a.len++;
                a.num[ i + 1 ] = 0;
            }
        if ( i < 24 )
                a.num[ i + 1 ] += a.num[ i ] / 10000;
            a.num[ i ] %= 10000;
        }
    return a;
}

//notice that a must larger than b
BigNum operator - ( const BigNum &c, const BigNum &b )
{
    int i, j;
    BigNum a;
    a = c;
    for ( i = b.len - 1; i >= 0; i-- )
    {
        a.num[ i ] -= b.num[ i ];
        if ( a.num[ i ] < 0 )
        {
            a.num[ i ] += 10000;
            a.num[ i + 1 ]--;
            if ( i + 2 == a.len && a.num[ i + 1 ] == 0 )
                a.len--;
        }
        if ( i == a.len - 1 && a.num[ i ] == 0 )
            a.len--;
    }
    return a;
}

BigNum operator * ( const BigNum &a, const BigNum &b )
{
    BigNum c;
    int i, j;
    c.len = a.len + b.len - 1;
    if ( c.len > 25 )
    c.len = 25;
    for ( i = 0; i < c.len; i++ )
        c.num[ i ] = 0;
    for ( i = 0; i < b.len; i++ )
        for ( j = 0; j < a.len && i + j < 25; j++ )
            c.num[ i + j ] += a.num[ j ] * b.num[ i ];
    for ( i = 0; i < c.len; i++ )
        if ( c.num[ i ] >= 10000 )
        {
            if ( i == c.len - 1 && i < 24 )
            {
                c.len++;
                c.num[ i + 1 ] = 0;
            }
        if ( i < 24 )
                c.num[ i + 1 ] += c.num[ i ] / 10000;
            c.num[ i ] %= 10000;
        }
    while ( !c.num[ c.len - 1 ] && c.len > 1 )
        c.len--;
    return c;
}

BigNum operator / ( const BigNum &e, const BigNum &b )
{
    int i, t1, t2;
    BigNum c, d, a;
    a = e;
    for ( i = a.len - 1; i >= 0; i-- )
    {
        c *= 10000;
        c += a.num[ i ];
        if ( b <= c )
        {
            t2 = b.num[ b.len - 1 ];
            if ( c.len > b.len )
                t1 = c.num[ c.len - 1 ] * 10000 + c.num[ c.len - 2 ];
            else
                t1 = c.num[ c.len - 1 ];
            t1 /= t2;
            d = b * t1;
            while ( c < d )
            {
                d -= b;
                t1--;
            }
            a.num[ i ] = t1;
            c -= d;
        }
        else
        {
            a.num[ i ] = 0;
            if ( i == a.len - 1 )
                a.len--;
        }
    }
    return a;
}

BigNum operator % ( const BigNum &a, const BigNum &b )
{
    int i, t1, t2;
    BigNum c, d;
    for ( i = a.len - 1; i >= 0; i-- )
    {
        c *= 10000;
        c += a.num[ i ];
        if ( b <= c )
        {
            t2 = b.num[ b.len - 1 ];
            if ( c.len > b.len )
                t1 = c.num[ c.len - 1 ] * 10000 + c.num[ c.len - 2 ];
            else
                t1 = c.num[ c.len - 1 ];
            t1 /= t2;
            d = b * t1;
            while ( c < d )
            {
                d -= b;
                t1--;
            }
            c -= d;
        }
    }
    return c;
}

BigNum operator + ( const BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    return a + c;
}

BigNum operator - ( const BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    return a - c;
}

BigNum operator * ( const BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    return a * c;
}

BigNum operator / ( const BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    return a / c;
}

BigNum operator % ( const BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    return a % c;
}

void operator += ( BigNum &a, const BigNum &b )
{
    int i, j;
    for ( i = 0; i < b.len; i++ )
    {
        if ( i < a.len )
            a.num[ i ] += b.num[ i ];
        else
        {
            a.num[ i ] = b.num[ i ];
            a.len++;
        }
    }
    for ( i = 0; i < a.len; i++ )
        if ( a.num[ i ] >= 10000 )
        {
            if ( i == a.len - 1 && i < 24 )
            {
                a.len++;
                a.num[ i + 1 ] = 0;
            }
        if ( i < 24 )
                a.num[ i + 1 ] += a.num[ i ] / 10000;
            a.num[ i ] %= 10000;
        }
}

//notice that a must larger than b
void operator -= ( BigNum &a, const BigNum &b )
{
    int i, j;
    for ( i = b.len - 1; i >= 0; i-- )
    {
        a.num[ i ] -= b.num[ i ];
        if ( a.num[ i ] < 0 )
        {
            a.num[ i ] += 10000;
            a.num[ i + 1 ]--;
            if ( i + 2 == a.len && a.num[ i + 1 ] == 0 )
                a.len--;
        }
        if ( i == a.len - 1 && a.num[ i ] == 0 )
            a.len--;
    }
}

void operator *= ( BigNum &a, const BigNum &b )
{
    BigNum c;
    int i, j;
    c.len = a.len + b.len - 1;
    for ( i = 0; i < c.len; i++ )
        c.num[ i ] = 0;
    for ( i = 0; i < b.len; i++ )
        for ( j = 0; j < a.len && i + j <= 24; j++ )
            c.num[ i + j ] += a.num[ j ] * b.num[ i ];
    for ( i = 0; i < c.len; i++ )
        if ( c.num[ i ] >= 10000 )
        {
            if ( i == c.len - 1 && i < 24 )
            {
                c.len++;
                c.num[ i + 1 ] = 0;
            }
        if ( i < 24 )
                c.num[ i + 1 ] += c.num[ i ] / 10000;
            c.num[ i ] %= 10000;
        }
    while ( !c.num[ c.len - 1 ] && c.len > 1 )
        c.len--;
    a = c;
}

void operator /= ( BigNum &a, const BigNum &b )
{
    int i, t1, t2;
    BigNum c, d;
    for ( i = a.len - 1; i >= 0; i-- )
    {
        c *= 10000;
        c += a.num[ i ];
        if ( b <= c )
        {
            t2 = b.num[ b.len - 1 ];
            if ( c.len > b.len )
                t1 = c.num[ c.len - 1 ] * 10000 + c.num[ c.len - 2 ];
            else
                t1 = c.num[ c.len - 1 ];
            t1 /= t2;
            d = b * t1;
            while ( c < d )
            {
                d -= b;
                t1--;
            }
            a.num[ i ] = t1;
            c -= d;
        }
        else
        {
            a.num[ i ] = 0;
            if ( i == a.len - 1 )
                a.len--;
        }
    }
}

void operator %= ( BigNum &a, const BigNum &b )
{
    int i, t1, t2;
    BigNum c, d;
    for ( i = a.len - 1; i >= 0; i-- )
    {
        c *= 10000;
        c += a.num[ i ];
        if ( b <= c )
        {
            t2 = b.num[ b.len - 1 ];
            if ( c.len > b.len )
                t1 = c.num[ c.len - 1 ] * 10000 + c.num[ c.len - 2 ];
            else
                t1 = c.num[ c.len - 1 ];
            t1 /= t2;
            d = b * t1;
            while ( c < d )
            {
                d -= b;
                t1--;
            }
            c -= d;
        }
    }
    a = c;
}

void operator += ( BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    a += c;
}

void operator -= ( BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    a -= c;
}

void operator *= ( BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    a *= c;
}

void operator /= ( BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    a /= c;
}

void operator %= ( BigNum &a, const int &b )
{
    BigNum c;
    c = b;
    a %= c;
}

int t;
BigNum n;

BigNum f1(BigNum x)
{
    return (x*x*x+x*x*3+x*2)/6;
}

BigNum f2(BigNum x)
{
    return (x*x+x)/2;
}

BigNum search1(BigNum x)
{
    BigNum l,r,m;
    l = 0;
    r = 1000000;
    while(l<r)
    {
        m =r-l;
        m /=2;
        m +=l;
        if(f1(m)<x)l = m+1;
        else r = m;
    }
    return r;
}
BigNum search2(BigNum x)
{
    BigNum l,r,m;
    l = 0;
    r = 10000000;
    while(l<r)
    {
        m = l+(r-l)/2;
        if(f2(m)<x)l = m+1;
        else r = m;
    }
    return r;
}

bool read_case()
{
    char nn[ 20 ];
    int i;
    if(t--==0)return false;
    scanf("%s",nn);
    n = 0;
    for ( i = 0; i < strlen( nn ); i++ )
    {
        n = n * 10 + nn[ i ] - '0';
    }
    return true;
}

void solve_case()
{
    BigNum i,j,k;
    i = search1(n);
    n-=f1(i-1);
    j = search2(n);
    k = n-f2(j-1);
    i.output( );
    printf(" ");
    j.output( );
    printf(" ");
    k.output( );
    printf("\n");
}

int main()
{
    scanf("%d",&t);
    while(read_case())
        solve_case();
    return 0;
}
